/*
//
//              INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license  agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in  accordance  with the terms of that agreement.
//    Copyright (c) 2007-2008 Intel Corporation. All Rights Reserved.
//
//
*/

#ifndef __UMC_AVS_SLICE_H
#define __UMC_AVS_SLICE_H

#include "ippdefs.h"
#include "umc_avs_context.h"
#include "umc_avs_slice_header.h"
#include "umc_avs_coeffs_buffer.h"

namespace UMC
{

// forward declaration of used types
struct AVS_SEQUENCE_HEADER;
struct AVS_PICTURE_HEADER;
class AVSPicture;
class MeFrame;

class AVSSlice
{
public:
    // Default constructor
    AVSSlice(void);
    // Destructor
    virtual
    ~AVSSlice(void);

    // Initialize coefficient buffer
    Status InitCoeffsBuffer(size_t iMinPieceToWrite, Ipp32s iNumPieces);
    // Get the size of initialized coeffs buffer
    size_t GetCoeffsBufferSize(void);

    // Obtain the pointer to the coeffs buffer to write
    inline
    Ipp16s *GetFree(void);
    // Obtain the pointer to the coeffs buffer to read
    inline
    const Ipp16s *GetUsed(void);

    // Advance the pointer to the free space
    inline
    void AdvanceFree(size_t iAdvance);
    // Advance the pointer to the used space
    inline
    void AdvanceUsed(size_t iAdvance);

    // Reset states of all processes in the slice
    virtual
    Status Reset(const AVS_SEQUENCE_HEADER *pSeqHeader,
                 const AVS_PICTURE_HEADER *pPicHeader);

    AVSPicture *m_pPic;                                         // (AVSPicture *) pointer to owning picture

    AVS_SLICE_HEADER m_SlcHeader;                               // (AVS_SLICE_HEADER) slice's header

    AVS_DECODING_CONTEXT m_decCtx;                              // (AVS_DECODING_CONTEXT) slice's decoding state
    bool m_bDecVacant;                                          // (bool) is the slice being decoded

    AVS_RECONSTRUCTING_CONTEXT m_recCtx;                        // (AVS_RECONSTRUCTING_CONTEXT) slice's reconstruction state
    bool m_bRecVacant;                                          // (bool) is the slice being reconstructed

    AVS_DEBLOCKING_CONTEXT m_debCtx;                            // (AVS_DEBLOCKING_CONTEXT) slice's deblocking state
    bool m_bDebVacant;                                          // (bool) is the slice being de-blocked

    AVS_ME_CONTEXT m_meCtx;                                     // (AVS_ME_CONTEXT) slice's ME state
    bool m_bMeVacant;                                           // (bool) is the slice being ME

    bool m_bError;                                              // (bool) can't continue decoding process

protected:

    AVSCoeffsBuffer m_coeffsBuf;                                // (AVSCoeffsBuffer) special coefficients buffer
};

inline
Ipp16s *AVSSlice::GetFree(void)
{
    return m_coeffsBuf.GetFree();

} // Ipp16s *AVSSlice::GetFree(void)

inline
const Ipp16s *AVSSlice::GetUsed(void)
{
    return m_coeffsBuf.GetUsed();

} // Ipp16s *AVSSlice::GetUsed(void)

inline
void AVSSlice::AdvanceFree(size_t iAdvance)
{
    m_coeffsBuf.AdvanceFree(iAdvance);

} // void AVSSlice::AdvanceFree(size_t iAdvance)

inline
void AVSSlice::AdvanceUsed(size_t iAdvance)
{
    m_coeffsBuf.AdvanceUsed(iAdvance);

} // void AVSSlice::AdvanceUsed(size_t iAdvance)


} // namespace UMC

#endif // __UMC_AVS_SLICE_H
